/*
 * QTeXPreview
 * Copyright (C) 2008, Philip Pronin (philip.pronin@gmail.com)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TOOLBOX_H
#define TOOLBOX_H

#include "toolBoxConfig.h"

#include <QSignalMapper>
#include <QWidget>

QT_FORWARD_DECLARE_CLASS(QTabWidget)
QT_FORWARD_DECLARE_CLASS(TeXFrontEnd)

/* XML config file structure:
  <?xml version="1.0" encoding="windows-1251"?>
  <toolbox version="1">
    <tab active="yes">
      <title>Tab Title</title>
      <command active="yes">
        <title>Command Title</title>
        <tex cursor="1">x+y</tex>
        <image>x+y</image>
      </command>
    </tab>
  </toolbox>
*/

class ToolBoxWidget : public QWidget {
	Q_OBJECT

public:
	ToolBoxWidget(QWidget* parent = 0);
	virtual ~ToolBoxWidget() {}

	void setEditor(TeXEditor* e);

public slots:
	void configure();

signals:
	void command(QObject* cmd);

private:
	void clear();
	void load();
	void save() const;
	void populate();

private:
	QSignalMapper* signalMapper;
	TeXEditor* editor;
	TeXFrontEnd* tex;
	QTabWidget* tabWidget;
	ToolBoxGroupList groups;
	QList<QWidget*> tabs;

	static const QString fileName;
};

class ToolButtonInfo : public QObject {
public:
	ToolButtonInfo(const ToolBoxCommand& _cmd, QObject* parent = NULL);
	ToolBoxCommand cmd;
};

#endif /* TOOLBOX_H */
